import { fromJS } from 'immutable';

import { UPDATE_NAV_BAR_LIST } from './constents';

const defaultState = fromJS({
  navbarList: [
    {
      id: 1, title: '积分与奖金', url: '/app/pointsAndBonus', active: true,
    },
    {
      id: 2, title: '目标管理', url: '/app/targetManagment', active: false,
    },
    {
      id: 3, title: '我的下级', url: '/app/subOrdinate', active: false,
    },
  ],
});

export default (state = defaultState, action: { type: string, value: any }) => {
  switch (action.type) {
    case UPDATE_NAV_BAR_LIST:
      return state.set('navbarList', action.value);
    default:
      return state;
  }
};
